home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / fgl110c.zip / 05-16.C < prev    next >
Text File  |  1992-01-31  |  2KB  |  79 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main(void);
  6.  
  7. void main()
  8. {
  9.    int mode, old_mode;
  10.    char string[5];
  11.  
  12. /* Ask for the video mode number */
  13.  
  14.    printf("Which video mode? ");
  15.    scanf("%d",&mode);
  16.  
  17. /* Make sure the entered value is valid */
  18.  
  19.    if (mode < 0 || mode > 23) {
  20.       printf("%d is not a valid video mode number.\n",mode);
  21.       exit(1);
  22.       }
  23.  
  24. /* Make sure the requested video mode is available */
  25.  
  26.    if (fg_testmode(mode,1) == 0) {
  27.       printf("Mode %d is not available on this system.\n",mode);
  28.       exit(1);
  29.       }
  30.  
  31. /* Establish the video mode */
  32.  
  33.    old_mode = fg_getmode();
  34.    fg_setmode(mode);
  35.  
  36. /* Perform mode-specific initializations */
  37.  
  38.    if (mode <= 3 || mode == 7)   /* text modes */
  39.       fg_cursor(0);
  40.  
  41.    else if (mode == 4 || mode == 5) { /* CGA color modes */
  42.       fg_palette(0,0);
  43.       fg_defcolor(14,3);
  44.       }
  45.  
  46.    else if (mode == 6) {         /* CGA two-color mode */
  47.       fg_palette(0,14);
  48.       fg_defcolor(14,1);
  49.       }
  50.  
  51.    else if (mode == 11)          /* Hercules mode */
  52.       fg_defcolor(14,1);
  53.  
  54.    else if (mode == 12)          /* Hercules low-res mode */
  55.       fg_defcolor(14,3);
  56.  
  57.    else if (mode == 17) {        /* VGA two-color mode */
  58.       fg_palette(1,14);
  59.       fg_setrgb(14,63,63,21);
  60.       fg_defcolor(14,1);
  61.       }
  62.  
  63. /* Display a message that includes the video mode number */
  64.  
  65.    fg_setcolor(14);
  66.    fg_text("I'm running in mode ",20);
  67.    sprintf(string,"%d. ",mode);
  68.    fg_text(string,3);
  69.  
  70. /* Wait for a keystroke */
  71.  
  72.    fg_waitkey();
  73.  
  74. /* Restore the original video mode and screen attributes */
  75.  
  76.    fg_setmode(old_mode);
  77.    fg_reset();
  78. }
  79.